<template>
    <div>
        <div class="title">
          <el-row>
            <el-col :span="1" style="width: 50px;">
              <span style="color:#757575;">位置 : </span>
            </el-col>
            <el-col :span="20">
              <span class="backtext">背景调查</span>
            </el-col>
          </el-row>
        </div>

        <div class="posttable">
            <el-row type="flex" justify="center">
                <el-col :span="23">
                    <div style="margin-top:15px;float: right;">
                        <el-button
                          @mousedown.native="editdown"
                          @mouseup.native="editup"
                          :class="{'active1' : newcolor1}"
                          size="small"
                          @click="editClick"
                          round
                          class="edit">修改
                        </el-button>
                    </div>
                </el-col>
            </el-row>

            <div class="backchecked">
                <div class="backcheckForm">
                    <el-row type="flex" justify="center">
                      <el-col :span="23">
                        <el-table
                          :data="tableData"
                          highlight-current-row
                          @current-change="handleCurrentChange"
                          ref="singleTable"
                          class="backtable"
                          style="width: 100%"
                        >
                          <el-table-column prop="customerName" label="客户名称"></el-table-column>
                          <el-table-column prop="name" label="姓名"></el-table-column>
                          <!-- <el-table-column prop="pusherName" v-if="recommend" label="推荐人"></el-table-column>
                          <el-table-column prop="postName" label="入职职位"></el-table-column>
                          <el-table-column prop="postLevel" label="职位级别"></el-table-column>
                          <el-table-column prop="area" label="入职地区"></el-table-column>
                          <el-table-column prop="education" label="学历"></el-table-column>
                          <el-table-column prop="phone" label="联系电话"></el-table-column>
                          <el-table-column prop="mail" label="邮箱"></el-table-column> -->
                          <el-table-column  label="身份证号" min-width="100%">
                            <template slot-scope="scope">
                              <!-- <span v-if="scope.row.identityPath !== null && scope.row.identityPath !== ''"><a class="other" :href="scope.row.identityPath" target="_blank">{{scope.row.identityFileName}}</a></span>
                              <span v-else>{{scope.row.identity}}</span> -->
                              <span>{{scope.row.idCard}}</span>
                            </template>
                          </el-table-column>
                          <el-table-column  label="毕业证编号">
                            <template slot-scope="scope">
                              <!-- <span v-if="scope.row.diplomaPath !== null && scope.row.diplomaPath !== ''"><a class="other" :href="scope.row.diplomaPath" target="_blank">{{scope.row.diplomaFileName}}</a></span>
                              <span v-else>{{scope.row.diploma}}</span> -->
                              <span>{{scope.row.idDiploma}}</span>
                            </template>
                          </el-table-column>
                          <el-table-column  label="学历证书编号">
                            <template slot-scope="scope">
                              <!-- <span v-if="scope.row.educationPath !== null && scope.row.educationPath !== ''"><a class="other" :href="scope.row.educationPath" target="_blank">{{scope.row.educationFilename}}</a></span>
                              <span v-else>{{scope.row.educations}}</span> -->
                              <span>{{scope.row.idEducation}}</span>
                            </template>
                          </el-table-column>
                          <el-table-column label="入职时间">
                            <template slot-scope="scope">
                              <span v-if="scope.row.realEntryScore == null">{{scope.row.entryTime}}</span>
                              <span v-else>{{scope.row.entryTime + scope.row.realEntryScore}}</span>
                            </template>
                          </el-table-column>
                          <el-table-column label="进场时间">
                            <template slot-scope="scope">
                              <span v-if="scope.row.realSceneScore == null">{{scope.row.sceneTime}}</span>
                              <span v-else>{{scope.row.sceneTime + scope.row.realSceneScore}}</span>
                            </template>
                          </el-table-column>
                          <el-table-column label="匹配结果" prop="imresults">
                            <template slot-scope="scope">
                              <el-tag v-if="scope.row.imresults === '暂未匹配'">暂未匹配</el-tag>
                              <el-tag type="success" v-else-if="scope.row.imresults === '匹配成功'">匹配成功</el-tag>
                              <el-tag type="danger" v-else="scope.row.imresults === '匹配失败'">匹配失败</el-tag>
                            </template>
                          </el-table-column>
                          <el-table-column label="调查">
                              <template slot-scope="scope">
                                  <el-button type="primary" size="mini" @click="checkIdInfo(scope.row)">信息验证</el-button>
                              </template>
                          </el-table-column>
                        </el-table>
                        <div class="pager">
                          <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="pagehandleCurrentChange"
                            :current-page="currentPage"
                            :page-sizes="[5,10,15]"
                            :page-size="pagesize"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="totalcount">
                          </el-pagination>
                        </div>
                      </el-col>
                    </el-row>

                </div>
            </div>
          </div>

          <el-dialog
            title="身份信息验证"
            :visible.sync="IdInfodialogVisible"
            width="420px"
            @close="editDialogClosed"
            :close-on-click-modal="false"
            class="addP">
             <el-form
                :model="backcheckForm"
                :rules="backcheckeRules"
                @current-change="handleCurrentChange"
                ref="backcheckRefs">
                <el-form-item label="用户姓名:" prop="name">
                  <el-input v-model="backcheckForm.name" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="身份证号:" prop="idCard">
                    <el-input v-model="backcheckForm.idCard" clearable placeholder="请输入身份证号"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
              <el-button class="cancel" round @click="IdInfodialogVisible = false">取 消</el-button>
              <el-button class="checked" round type="primary" @click="this.queryInfo">认证信息</el-button>
            </span>
          </el-dialog>

          <el-dialog
              title="错误"
              :visible.sync="editdialogVisible"
              width="30%"
              :before-close="handleClose"
              class="deletedialog">
              <div style="text-align: center">
                <i class="el-icon-warning" style="font-size: 20px;color: #fcb543;">
                  <span style="font-size: 16px;color: #333;margin-left: 12px;">尚未选择任何信息</span>
                </i>
              </div>
              <span slot="footer" class="dialog-footer">
                <el-button class="sure" round @click="handleOpen">确 定</el-button>
                <el-button round @click="handleClose" class="cancel">取 消</el-button>
              </span>
            </el-dialog>

           <el-dialog
            title="修改信息"
            :visible.sync="IdInfodialogVisible1"
            :model="backcheckForm1"
            :rules="backcheckeRules1"
            width="420px"
            @close="editDialogClosed1"
            :close-on-click-modal="false"
            class="addP">
             <el-form
                :model="backcheckForm1"
                :rules="backcheckeRules1"
                ref="backcheckRefs1">
                <!-- <el-form-item label="用户姓名:" prop="name">
                  <el-input v-model="backcheckForm1.name" :disabled="true"></el-input>
                </el-form-item> -->
                <el-form-item label="身份证号:" prop="idCard">
                  <el-input v-model="backcheckForm1.idCard" clearable placeholder="请输入身份证号"></el-input>
                </el-form-item>
                <el-form-item label="毕业证编号:" prop="idDiploma">
                    <el-input v-model="backcheckForm1.idDiploma" clearable placeholder="请输入毕业证编号"></el-input>
                </el-form-item>
                 <el-form-item label="学位证编号:" prop="idEducation">
                    <el-input v-model="backcheckForm1.idEducation" clearable placeholder="请输入学位证编号"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
              <el-button class="cancel" round @click="IdInfodialogVisible1 = false">取 消</el-button>
              <el-button class="checked" round type="primary" @click="this.queryInfo1">确认修改</el-button>
            </span>
          </el-dialog>

    </div>
</template>

<script>

import axios from 'axios'
import tagsView from '../../store/modules/tagsView'

export default {
  data() {
    var checkId = (rule,value,callback) => {
      const cardId = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
      if(cardId.test(value)){
          return callback()
      }else{
          callback(new Error('请输入正确的身份证号'))
      }
    }
    return {
        secondshow: false,
        recommend: false,
        tableData: [],
        input2:'',
        fileUrl: "",
        resumeId: "",
        jiaofu: true,
        secondshow: false,
        currentRow: null,
        theme: "",
        msg: "",
        certificate: "",
        salary: "",
        probation: "",
        changeoradd: "",
        remarks: "",
        welfare: "",
        socialsecurity: "",
        entryCompany: "",
        originalFilename: "",
        entryTime: "",
        realEntryScore: "",
        sceneTime: "",
        realSceneScore: "",
        userInfo: "",
        currentPage: 1,
        pagesize: 15,
        totalcount: 0,
        sendEmailKey: true,
        timeDialogVisible: false,
        editdialogVisible: false,
        dialogMailVisible: false,
        hrdialogVisible: false,
        editBool: false,
        sendBool: false,
        time: {
          entryTime: null,
          sceneTime: null,
          realEntryScore: '',
          realSceneScore: ''
        },
        timelist: ['上午', '下午'],
        time1:'',
        time2:'',
        rule: {
          entryTime: [
            {required: true, message: "请输入入职时间", trigger: "blur"}
          ],
          sceneTime: [
            {required: true, message: "请输入进场时间", trigger: "blur"}
          ],
          realEntryScore: [
            {required: true, message: '请选择入职时间范围', trigger: 'change'}
          ],
          realSceneScore: [
            {required: true, message: '请选择进场时间范围', trigger: 'change'}
          ],
        },
        actionurl: null,
        actionurl1: null,
        actionurl2: null,
        fileList: [],
        file: {},
        filetype: true,
        selectfile: false,
        fileList1: [],
        file1: {},
        filetype1: true,
        selectfile1: false,
        fileList2: [],
        file2: {},
        filetype2: true,
        IdInfodialogVisible: false,
        newcolor1: false,
        currentRow: null,
        editdialogVisible: false,
        backcheckForm:{
            resumeId: null,
            name:'',
            idCard:''
        },
        backcheckeRules:{
          idCard:[
            { required: true, message: '请输入身份证号', trigger: 'blur' },
            { validator:checkId, trigger: 'blur'}
          ]
        },
        IdInfodialogVisible1: false,
        backcheckForm1: {
          resumeId: null,
          idCard:'',
          idDiploma:'',
          idEducation:''
        },
        backcheckeRules1:{
          idCard:[
            { required: true, message: '请输入身份证号', trigger: 'blur' },
            { validator:checkId, trigger: 'blur'}
          ],
          idDiploma:[
             { required: true, message: '请输入毕业证编号', trigger: 'blur' },
          ],
          idEducation:[
             { required: true, message: '请输入学位证编号', trigger: 'blur' }
          ]
        },


    }
  },
  created() {
      //身份证身份证文件接口地址
      this.actionurl = this.url + "/statistics/entryInfo/identityUpload";
      //毕业证文件接口地址
      this.actionurl1 = this.url + "/statistics/entryInfo/diplomaUpload";
      //学历证书接口
      this.actionurl2 = this.url + "/statistics/entryInfo/educationUpload";
      if (tagsView.state.identity == 7) {
        this.jiaofu = false;
      }
      this.getData();
  },
  methods:{
     tableshow() {
        this.secondshow = false;
        this.secondtitle = "";
      },
     getData() {
        this.tableshow();
        axios.post(this.url + "/entry/apply/getApplyList", {
          condition: this.input2,
          pageNum: this.currentPage,
          pageSize: this.pagesize
        }).then(res => {
          this.unlogin(res.data.code)
          if (res.data.code == 200) {
            this.tableData = res.data.data.list;
            this.totalcount = res.data.data.total;
            //console.log(this.tableData)
          }
        })
      },
      handleSizeChange(val) {
        this.pagesize = val;
        this.getData();
      },
      pagehandleCurrentChange(val) {
        this.currentPage = val;
        this.getData();
      },
      //信息验证弹框
      queryInfo() {
        this.$refs.backcheckRefs.validate((valid) => {
          if(valid) {
            console.log(this.backcheckForm)
            axios.post(this.url + "/referenceCheck/getbirth",{
              resumeId: Number(this.backcheckForm.resumeId),
              name: this.backcheckForm.name,
              idCard: this.backcheckForm.idCard
            }).then(res => {
              this.unlogin(res.data.code)
              if(res.data.code == 200) {
                  this.getData();
                  this.IdInfodialogVisible = false;
              }
            })
          }
        })
      },

      checkIdInfo(info) {
        this.backcheckForm.resumeId = info.resumeId;
        this.backcheckForm.name = info.name;
        this.IdInfodialogVisible = true;
        //console.log(id);
      },
       editDialogClosed() {
          this.$refs.backcheckRefs.resetFields();
      },
      //鼠标按下修改按钮
      editdown() {
        this.newcolor1 = true;
      },
      //修改按钮弹起
      editup() {
        this.newcolor1 = false;
      },
      //点击当前行触发事件
      clickHandler(row) {
        this.rowId = row.id;
      },
      //修改弹出框出现
      handleOpen() {
        this.editdialogVisible = false;
        document.documentElement.style.overflow = 'hidden';
      },
      //关闭修改弹出框
      handleClose(done) {
        this.editdialogVisible = false;
        document.documentElement.style.overflow = 'auto';
      },
      handleCurrentChange(info) {
          this.currentRow = info;
      },
      editClick() {
        if(this.currentRow == null) {
          this.editdialogVisible = !this.editdialogVisible;
        } else {
           this.IdInfodialogVisible1 = true;
           this.backcheckForm1.resumeId = this.currentRow.resumeId;
           this.backcheckForm1.idCard = this.currentRow.idCard;
           this.backcheckForm1.idDiploma = this.currentRow.idDiploma;
           this.backcheckForm1.idEducation = this.currentRow.idEducation;
        }
      },
      editDialogClosed1() {
          this.$refs.backcheckRefs1.resetFields();
      },
      queryInfo1() {
          this.$refs.backcheckRefs1.validate((valid) => {
              if(valid) {
                axios.post(this.url + "/referenceCheck/updatedate",{
                resumeId: Number(this.backcheckForm1.resumeId),
                idCard: this.backcheckForm1.idCard,
                idDiploma: this.backcheckForm1.idDiploma,
                idEducation: this.backcheckForm1.idEducation
              }).then(res => {
                this.unlogin(res.data.code)
                if(res.data.code == 200) {
                    this.getData();
                    this.IdInfodialogVisible1 = false;
                }
              })
            }
          })

      }
  }
}
</script>

<style scoped>
  .title {
      background-color: #fff;
      height: 40px;
      line-height: 40px;
      font-size: 14px;
      padding-left: 20px;
      margin-top: 6px;
      margin-bottom: 6px;
    }
  .posttable {
    background-color: #fff;
  }

  .edit {
    width: 65px;
    height: 28px;
    opacity: 0.86;
    color: #fff;
    background: linear-gradient(to bottom, #00cebf 0%, #009085 100%);
    padding: 7px 10px !important;
  }

  .edit:hover {
    color: #fff !important;
  }

  .active1 {
    background: linear-gradient(to bottom, #1cf1e3 0%, #379b94 100%);
  }

  .backtext {
    color: #1099ff;
  }

  .backchecked {
    width: 100%;
    background-color: #fff;
  }

  .backcheckForm {
    padding: 20px 0 0 10px;
  }

 .pager {
    width: 100%;
    overflow: hidden;
    position: relative;
    margin-top: 10px;
    margin-bottom: 10px;
  }

  .el-pagination {
    margin-left: 50%;
    transform: translateX(-50%);
  }

   .other {
    color: #1198ff;
    cursor: pointer;
    text-decoration: none;
  }
  .checked{
    color: #fff;
    background: linear-gradient(to bottom, #5696f8 0%, #4e6ef5 100%);
    margin-left: 30px;
  }
  .checked:hover{
    color: #fff;
  }


</style>
